﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Shrestha.Charts.Graph
{
    /// <summary>
    /// Interaction logic for TriGraphStoryLines.xaml
    /// </summary>
    public partial class TriGraphStoryLines : Window
    {
        private readonly ChartWindowViewModel _vm;
        private string filterString;

        public TriGraphStoryLines()
        {
            InitializeComponent();
        }

        public TriGraphStoryLines(ChartWindowViewModel cwvm)
        {

            InitializeComponent();
            this._vm = cwvm;
        }

        private void buttonCreate_Click(object sender, RoutedEventArgs e)
        {
            filterString = "";
        
            string[] strs = textSearchString.Text.Split(',');
            foreach (string str in strs)
            {
                filterString += _vm.GetRunner().CharacterName + " = "+ str + " OR ";
            }
            filterString = filterString.Substring(0, filterString.Length - 4);
            _vm.ShowStoryLines = true;
            this.Close();
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            _vm.ShowStoryLines = false;
            this.Close();
        }

        internal string GetFilterString()
        {
            return filterString;
        }       
    }
}
